package client;

import gui.Payment_GUI;

import java.io.Serializable;

/**
 * 
 * Handles members subscription
 *
 */
public class Subscribe implements Serializable{

	/**
	 * subscription type(month/year)
	 */
	int type;
	/**
	 * member id number
	 */
	int usrID;
	
	/**
	 * Initialize member id number
	 * @param user initialize user id number
	 */
	public Subscribe(int user)
	{
		usrID=user;
	}
	
	/**
	 * Subscribe member
	 * @param type 1 for monthly,2 for yearly
	 * @return 1 if subscription succeeded,else 0
	 */
	public int submit(int type)
	{
		this.type=type;
		ObjHandle.sendToServer(this);
		return (Integer)Main.clie.getResult();
	}
	
	/**
	 * Gets subscription type
	 * @return subscription type (month/year)
	 */
	public int getType()
	{
		return type;
	}
	
	/**
	 * Gets member ID number
	 * @return member id number
	 */
	public int getUserID()
	{
		return usrID;
	}
	
	public static void checkSubscribe(Integer uid)
	{
		String [] sn=new String[2];
		sn[0]="Check Subscribe";
		sn[1]=uid.toString();
		
		ObjHandle.sendToServer(sn);
		
		Payment_GUI.rs= (Object[]) Main.clie.getResult();
	}
}
